﻿using Framework.Core;
using Xunit;
using Xunit.Extensions;

namespace Framework.Tests.Core
{
    public class StringExtensionTest
    {
        [Theory]
        [InlineData(null)]
        [InlineData("")]
        [InlineData("    ")]
        public void Should_return_string_empty_for_null(string s)
        {
            Assert.Equal(string.Empty, s.SafeTrim());
        }

        [Theory]
        [InlineData(" toto    ")]
        [InlineData("toto    ")]
        [InlineData(" toto")]
        [InlineData("toto")]
        public void Should_return_trimmed_string(string s)
        {
            Assert.Equal("toto", s.SafeTrim());
        }

        [Theory]
        [InlineData(null, "")]
        [InlineData("test", "test")]
        [InlineData("", "")]
        public void Should_return_string_empty_for_null(object o, string expected)
        {
            Assert.Equal(expected, o.SafeToString());
        }
    }
}
